package com.hnkywl.sts.action.htgl;

import com.hnkywl.sts.dao.htgl.ZjbchtDao;
import com.hnkywl.sts.entity.htgl.Xsht;
import com.hnkywl.sts.entity.organ.Lj;
import com.hnkywl.sts.entity.sys.Yg;
import com.hnkywl.sts.entity.xsgl.Xsd;
import com.hnkywl.sts.service.htgl.ZjbchtService;
import com.hnkywl.sts.service.organ.LjwhService;
import com.hnkywl.sts.service.sys.YgService;
import com.hnkywl.sts.service.xsgl.XsdService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by HL on 2016/4/18.
 */
@Namespace("/htgl/zjbchtgl")
public class ZjbchtglAction extends SimpleActionSupport {
    private ZjbchtService zjbchtService;

    private String zt;
    private String xslx;
    private String htbh;
    private Long ssgsId;
    private Long ssbmId;
    private Long xsrId;
    private Long hzfId;
    private Date startDate;
    private Date endDate;
    private String xhtbm;
    private int page;
    //分页组件 页面大小
    private int rows;
    private Xsht xsht;
    private Long gsId;
    private Long zggsId;
    private Yg yg;
    private Long xshtId;
    private String xyType;
    private Long htdyId;
    private String xshtHtbm;
    private String xshtEmwtime;
    private LjwhService ljwhService;

    private Double ce;

    private Xsd xsd;
    private Long xsdId;
    private XsdService xsdService;
    private String htce;
    private ZjbchtDao zjbchtDao;
    @Action("zjbchtList")
    public void zjbchtList() {
        this.renderJson(this.zjbchtService.findZjbchtList1( htbh,  page, rows));
    }


     @Action("zjbcht_detail")
    public String xshtContent() {
        try {
            gsId = YgService.getCurrentYgGsId();
            zggsId = YgService.getCurrentYgZgGsId();
            yg = YgService.getCurrentYg();
           // xsd = this.xsdService.findXsdDetail(xsdId);

            if (xshtId != null) {
                xsht = this.zjbchtService.findZjbchtDetail(xshtId);
                if (null != xsht.getXy()) {
                    xyType = xsht.getXy().getClass().getSimpleName();
                }
            } else {
                this.startDate = new Date();
            }
            if (null != xsht && null != xsht.getLj()) {
                Lj lj = this.ljwhService.find(xsht.getLj().getId());
                if (null != lj && null != lj.getXshtmb()) {
                    htdyId = lj.getXshtmb().getId();
                    xshtHtbm = xsht.getHtbm();
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
                    xshtEmwtime = simpleDateFormat.format(xsht.getLastUpdated());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return SUCCESS;
    }



   @Action("httk_content")
    public String xshtContent1() {
        try {
            gsId = YgService.getCurrentYgGsId();
            zggsId = YgService.getCurrentYgZgGsId();
            yg = YgService.getCurrentYg();
            xsd = this.xsdService.findXsdDetail(xsdId);
          // htce=this.zjbchtDao.findhtce(xsd.getId());
            if (xshtId != null) {
                xsht = this.zjbchtService.findZjbchtDetail(xshtId);

                //htce=this.zjbchtService.findhtce(xsd.getId());

                if (null != xsht.getXy()) {
                    xyType = xsht.getXy().getClass().getSimpleName();
                }
            } else {
                this.startDate = new Date();
            }
            if (null != xsht && null != xsht.getLj()) {
                Lj lj = this.ljwhService.find(xsht.getLj().getId());
                if (null != lj && null != lj.getXshtmb()) {
                    htdyId = lj.getXshtmb().getId();
                    xshtHtbm = xsht.getHtbm();
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
                    xshtEmwtime = simpleDateFormat.format(xsht.getLastUpdated());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return SUCCESS;
    }

    @Action("zjbchtgl_htmx")
    public void xshtmxDetail() {
        if (rows == 0)
            rows = -1;
        this.renderJson(this.zjbchtService.findZjbchtmxDetail(xshtId));
    }

    //===========================


    public Double getCe() {
        return ce;
    }

    public void setCe(Double ce) {
        this.ce = ce;
    }

    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Yg getYg() {
        return yg;
    }

    public void setYg(Yg yg) {
        this.yg = yg;
    }

    public Long getZggsId() {
        return zggsId;
    }

    public void setZggsId(Long zggsId) {
        this.zggsId = zggsId;
    }

    public Long getXshtId() {
        return xshtId;
    }

    public void setXshtId(Long xshtId) {
        this.xshtId = xshtId;
    }

    public String getXyType() {
        return xyType;
    }

    public void setXyType(String xyType) {
        this.xyType = xyType;
    }

    public Long getHtdyId() {
        return htdyId;
    }

    public void setHtdyId(Long htdyId) {
        this.htdyId = htdyId;
    }

    public String getXshtHtbm() {
        return xshtHtbm;
    }

    public void setXshtHtbm(String xshtHtbm) {
        this.xshtHtbm = xshtHtbm;
    }

    public String getXshtEmwtime() {
        return xshtEmwtime;
    }

    public void setXshtEmwtime(String xshtEmwtime) {
        this.xshtEmwtime = xshtEmwtime;
    }

    public Xsht getXsht() {
        return xsht;
    }

    public void setXsht(Xsht xsht) {
        this.xsht = xsht;
    }

    public String getZt() {
        return zt;
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getXslx() {
        return xslx;
    }

    public void setXslx(String xslx) {
        this.xslx = xslx;
    }

    public String getHtbh() {
        return htbh;
    }

    public void setHtbh(String htbh) {
        this.htbh = htbh;
    }

    public Long getSsgsId() {
        return ssgsId;
    }

    public void setSsgsId(Long ssgsId) {
        this.ssgsId = ssgsId;
    }

    public Long getSsbmId() {
        return ssbmId;
    }

    public void setSsbmId(Long ssbmId) {
        this.ssbmId = ssbmId;
    }

    public Long getXsrId() {
        return xsrId;
    }

    public void setXsrId(Long xsrId) {
        this.xsrId = xsrId;
    }

    public Long getHzfId() {
        return hzfId;
    }

    public void setHzfId(Long hzfId) {
        this.hzfId = hzfId;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public String getXhtbm() {
        return xhtbm;
    }

    public void setXhtbm(String xhtbm) {
        this.xhtbm = xhtbm;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public Xsd getXsd() {
        return xsd;
    }

    public void setXsd(Xsd xsd) {
        this.xsd = xsd;
    }

    public Long getXsdId() {
        return xsdId;
    }

    public void setXsdId(Long xsdId) {
        this.xsdId = xsdId;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public String getHtce() {
        return htce;
    }

    public void setHtce(String htce) {
        this.htce = htce;
    }

    @Autowired
    public void setLjwhService(LjwhService ljwhService) {
        this.ljwhService = ljwhService;
    }

    @Autowired
    public void setZjbchtService(ZjbchtService zjbchtService) {
        this.zjbchtService = zjbchtService;
    }
    @Autowired

    public void setXsdService(XsdService xsdService) {
        this.xsdService = xsdService;
    }
    @Autowired

    public void setZjbchtDao(ZjbchtDao zjbchtDao) {
        this.zjbchtDao = zjbchtDao;
    }
}
